package com.hooware.dao;

import com.hooware.domain.Product;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface IProductDao {

    /**
     * 查询所有产品
     * @return
     */
    @Select("select * from product")
    List<Product> findAll();

    /**
     * 保存产品
     * @param product
     */
    //@Insert("insert into product values((select sys_guid() from dual),#{productNum},#{productName},#{cityName},#{departureTime},#{productPrice},#{productDesc},#{productStatus})")
    @Insert("insert into product values(default,#{productNum},#{productName},#{cityName},#{departureTime},#{productPrice},#{productDesc},#{productStatus})")
    void saveProduct(Product product);

    /**
     * 根据id查询product
     * @param id
     * @return
     */
    @Select("select * from product where id = #{id}")
    Product findById(String id);
}
